package DBside;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import main.SharedPref;
import Utils.Concurrent.TaskRunError;

public class DB_Stats {
	
	public String getDBstats(Statement stmt) throws TaskRunError{

			ResultSet rs;
			String str = "";
			try {
				rs = stmt.executeQuery("select TABLE_NAME as Name, TABLE_ROWS as rows from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = '"+SharedPref.schemaName+"'");
				int i = 1;
				while(rs.next()){
					str += i+". In the table: "+rs.getString(1)+" there are: "+rs.getInt(2)+" entities\r";
					i++;
				}
				rs.close();

			} catch (SQLException e) {
				System.out.println("ERROR executeQuery - " + e.toString());
				// java.lang.System.exit(0);
				throw new TaskRunError("Connection Error");
			}
			return str;
		}

}
